<me:UIVRK x:Class="WPFExcelReport.TSTEKVR"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL"  
                    xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                     xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                    xmlns:KD="clr-namespace:WPFExcelReport;assembly=TKDSTAMM"  
                    xmlns:LS="clr-namespace:WPFExcelReport;assembly=TLIEFDAT"  
                    xmlns:HR="clr-namespace:WPFExcelReport;assembly=THRSTAMM"  
                    xmlns:DR="clr-namespace:WPFExcelReport;assembly=TDRAUFTR" 
                    xmlns:ZA="clr-namespace:WPFExcelReport;assembly=TZABED"   
                    xmlns:VRP="clr-namespace:WPFExcelReport;assembly=TVRPOS" 
                    xmlns:EKP="clr-namespace:WPFExcelReport;assembly=TEKPOS"     
                    xmlns:ZB="clr-namespace:WPFExcelReport;assembly=TVKZUAB"    
                    xmlns:TXT="clr-namespace:WPFExcelReport;assembly=TTXTIND"   
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:UIVRK.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTConverter  x:Key="not"/>
        <ucd:Divideby100 x:Key="d100"/>
        <ucd:PNumConverter  x:Key="pnum"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
    </me:UIVRK.Resources>
    <DockPanel IsEnabled="{Binding IsBusy,ElementName=TV,Converter={StaticResource not}}">
        <ex:AniScrollViewer DockPanel.Dock="Bottom" 
                        Visibility="{Binding IsShowBottom,ElementName=TV,Converter={StaticResource bv}}">
            <StackPanel >
                <ZB:TVKZUAB Name="cZBP" Margin="10" IsAuto="True"  MaxHeight="300"  
                            VKZSA="EK"
                            ORDERNUM="{Binding AUF,ElementName=cVKP}"  />
            </StackPanel>
        </ex:AniScrollViewer>
        <ex:AniScrollViewer DockPanel.Dock="Right" 
                    MaxWidth="400"
                    Visibility="{Binding IsShowRight,ElementName=TV,Converter={StaticResource bv}}" >
            <StackPanel>
                <KD:TKD  ORDERNUM="{Binding KUNDNR,ElementName=cVRK}"  
                         KDBLOCK="{Binding KDBLOCK,ElementName=cVKP}"   
                         待处理现金="{Binding 待处理现金,ElementName=cVRP}"   
                         已付款="{Binding 已付款,ElementName=cVRP}"   
                         已开票="{Binding 已开票,ElementName=cVRP}"     
                         IsSaved="{Binding IsSaved,ElementName=cVRP}"
                         IsEdit="{Binding IsEdit,ElementName=cVRP}" 
                         />
                <ZA:TZA03 Grid.Column="2"  ORDERNUM="{Binding ZAHLBED,ElementName=cVRK}" />
                <TXT:TXTITX Grid.Row="1"   Grid.Column="1"
                         Name="cTxt" 
                             TART="VKT"
                         IsAuto="False"
                         SIND="{Binding TXTISIND,ElementName=cVKP}"   
                        DEFTXT="{Binding DEFTXT,ElementName=cVKP}"  
                        />
            </StackPanel>
        </ex:AniScrollViewer>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="1*"></RowDefinition>
                <RowDefinition Height="2*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="1*"/>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Row="0">
                    <WrapPanel  VerticalAlignment="Top">
                        <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                                </Button.Background>
                            </Button>
                        </Grid>
                        <WrapPanel VerticalAlignment="Top" >
                         
                            <Button Margin="10,0,0,0" Width="100" Content="{Binding Source={Localization:Translate Word=订单确认付款}}" Click="EKKPaymentCommand" />
                            <Button Margin="10,0,0,0" Width="100" Content="{Binding Source={Localization:Translate Word=发货前付款}}" Click="VVPaymentCommand" />
                            <Button Margin="10,0,0,0" Width="100" Content="{Binding Source={Localization:Translate Word=尾款}}" Click="RESTPaymentCommand" />
                            <Button Margin="10,0,0,0" Width="100" Content="{Binding Source={Localization:Translate Word=未开票}}" Click="QueryCommand" />
                            <Button Margin="10,0,0,0" Width="100" Content="{Binding Source={Localization:Translate Word=未支付}}" Click="OpenVRCommand" />
                            <Button Content="{Binding Source={Localization:Translate Word=申请代销佣金}}" Click="CommissionCommand" />
                        </WrapPanel>

                      
                    </WrapPanel>
                    <WrapPanel>
                        <LS:TSLS02 KEY="{Binding LIEFNR,ElementName=TV}" IsEdit="True" MinWidth="100"/>
                        <TextBlock Text="{Binding Source={Localization:Translate Word=含已付}}" FontStyle="Italic"/>
                        <CheckBox IsChecked="{Binding IsPaid,ElementName=TV}"/>

                        <Grid Margin="10,0,0,0" VerticalAlignment="Top" 
                      Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                <Button.Background>
                                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                                </Button.Background>
                            </Button>
                        </Grid>
                        <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=订单类型}}"/>
                            <TextBlock Grid.Column="1" FontSize="16"   
                              Text="{Binding AUFTYP,ElementName=TV}" Width="20" />
                        </Grid>
                        <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=订单号}}"/>
                            <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2" PRE="  "   IsAutoClear="True" CharacterCasing="Upper" 
                              Text="{Binding KRS,ElementName=TV}" Width="30" />
                            <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6"  IsAutoClear="True" PRE="000000" 
                              Text="{Binding LFD,ElementName=TV}" KeyUp="AUF_Enter" Width="90" />
                        </Grid>
                    </WrapPanel> 
                </StackPanel>

                <me:TVR04  Grid.Column="1" x:Name="cVRK"
                        ORDERNUM="{Binding KEY,ElementName=TV}" IsAuto="False"
                        IsNew="{Binding IsNew,ElementName=TV}"
                        IsEdit="{Binding IsEdit,ElementName=TV}"
                        IsSaved="{Binding IsSaved,ElementName=TV}"
                        IsShowBottom="{Binding IsShowBottom,ElementName=TV}"
                        IsShowTop="{Binding IsShowTop,ElementName=TV}"
                        IsShowLeft="{Binding IsShowLeft,ElementName=TV}"
                        IsShowRight="{Binding IsShowRight,ElementName=TV}"
               />
            </Grid>
            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="1*"/>
                </Grid.ColumnDefinitions>
                <DataGrid   Grid.Column="0"
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"  
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}"  
                   IsSynchronizedWithCurrentItem="True" 
                   x:Name="dlgMaster"  
                   RowDetailsVisibilityMode="Visible">
                    <DataGrid.Columns>
                        <DataGridCheckBoxColumn Width="40" Binding="{Binding Path=IsSelected,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type DataGridRow}}}">
                            <DataGridCheckBoxColumn.HeaderTemplate>
                                <DataTemplate>
                                    <CheckBox x:Name="ckbSelectedAll" Checked="ckbSelectedAll_Click" Unchecked="ckbSelectedAll_Unchecked"></CheckBox>
                                </DataTemplate>
                            </DataGridCheckBoxColumn.HeaderTemplate>
                        </DataGridCheckBoxColumn>
                        <DataGridTextColumn Binding="{Binding Path=LSLIEFNA,Converter={StaticResource gb2312}}"  Header="{Binding Source={Localization:Translate Word=供应商}}" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRKRENR, Mode=TwoWay}"  Header="{Binding Source={Localization:Translate Word=发票}}" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRKZAHLBED}"  Header="{Binding Source={Localization:Translate Word=付款方式}}" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRPAUFKRS, Mode=TwoWay}"   Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRPAUFLFD, Mode=TwoWay}"   Header="{Binding Source={Localization:Translate Word=采购单}}" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRPAUFPOS, Mode=TwoWay}"   Header="" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRKGESWERTN, Mode=TwoWay}"   Header="{Binding Source={Localization:Translate Word=发票金额}}" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRKWAWERT, Mode=TwoWay}"   Header="{Binding Source={Localization:Translate Word=货物价值}}" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRKZUAB, Mode=TwoWay}"   Header="{Binding Source={Localization:Translate Word=附加费}}" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRPRENR, Converter={StaticResource ResourceKey=pnum}}" Header="{Binding Source={Localization:Translate Word=发票号}}" Width="Auto" />
                        <DataGridTextColumn Binding="{Binding Path=VRPREPOS, Converter={StaticResource ResourceKey=pnum}}" Header="{Binding Source={Localization:Translate Word=行}}" Width="Auto" />
                    </DataGrid.Columns>
                </DataGrid  >
                <EKP:TFEKP Grid.Column="1" 
                 Name="cVKP"
                 IsShowBottom="{Binding IsShowBottom,ElementName=TV}"
                 IsShowTop="{Binding IsShowTop,ElementName=TV}"
                 IsShowLeft="{Binding IsShowLeft,ElementName=TV}"
                 IsShowRight="{Binding IsShowRight,ElementName=TV}"
                 ORDERNUM="{Binding VVKP,ElementName=TV}"/>
            </Grid>
            

            <VRP:TEKVR05 Grid.Row="2"
                 Name="cVRP"
                 Margin="10,0,0,0"
                 ARTST="F"  
                 IsCanPay="True"
                 IsBlocked="{Binding IsInactive,ElementName=cVKP}"
                 KUNDNR="{Binding KUNDNR,ElementName=cVRK}"
                 ORDERNUM="{Binding VRP,ElementName=TV}"
                 VKP="{Binding AUF,ElementName=cVKP}"
                 RENR="{Binding KEY,ElementName=cVRK}"
                 IsNew="{Binding IsNew,ElementName=TV}"
                 IsEdit="{Binding IsEdit,ElementName=TV}"
                 IsFilterByVKP="True" 
                 IsShowBottom="{Binding IsShowBottom,ElementName=TV}"
                 IsShowTop="{Binding IsShowTop,ElementName=TV}"
                 IsShowLeft="{Binding IsShowLeft,ElementName=TV}"
                 IsShowRight="{Binding IsShowRight,ElementName=TV}"
                 IsSaved="{Binding IsSaved,ElementName=TV}"
                 />
        </Grid>
    </DockPanel>
</me:UIVRK>
